@extends('layouts.console_header')

@section('title', '已下架商家列表')

@section('resources')
    @parent
    <style>
        .shop_eweima{position: fixed;top: 50%;left: 50%;width: 600px;height: 415px;margin-top: -200px;margin-left: -300px;background-color: #fff;border: 1px solid #333;display: none;}
        .shop_eweima_content li{text-align: center;margin: 10px;}
        .shop_eweima .shop_downloadewm{width: 350px;height: 40px;margin: 0 125px;background-color: #9955c6;color: #fff;border-radius: 10px;position: absolute;bottom: 20px;}
        .shop_title{height: 50px;line-height: 50px;border-bottom: 1px solid #333;}
        .shop_title p{width: 550px;text-align: center;}
        .shop_title img{width: 30px;margin: 10px;}
    </style>
@endsection

@section('content')
<section class="user_list">
    <p class="fz_14 account_title">
        <span style="color: #7f7f7f;"><a href="/console/index">首页</a>>商家版运营></span>
        <span class="co_violet">已下架商家列表</span>
    </p>
    <table id="example" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>序号</th>
                <th>商家代码</th>
                <th style="width: 200px;">商家名称</th>
                <th>商家登录账号</th>
                <th>一级分类</th>
                <th>二级分类</th>
                <th>翻倍日</th>
                <th>商务姓名</th>
                <th>入驻日期</th>
                <th style="width: 230px;">操作</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>序号</th>
                <th>商家代码</th>
                <th>商家名称</th>
                <th>商家登录账号</th>
                <th>一级分类</th>
                <th>二级分类</th>
                <th>翻倍日</th>
                <th>商务姓名</th>
                <th>入驻日期</th>
                <th>操作</th>
            </tr>
        </tfoot>
        <tbody>
            @foreach($lists as $list)
                <tr>
                @if(!isset($i))
                    <td>{{$i=1}}</td>
                @else
                    <td>{{++$i}}</td>
                @endif
                    <td>{{$list['shopcode']}}</td>
                    <td>{{$list['shopname']}}</td>
                    <td>{{$list['parentmobile']}}</td>
                    <td>{{$list['firstclassname']}}</td>
                    <td>{{$list['secondclassname']}}</td>
                @if($list['todayevent'] == '1')
                    <td>是</td>
                @else
                    <td>否</td>
                @endif
                    <td>{{$list['managername']}}</td>
                    <td>{{date('Y-m-d H:i', strtotime($list['created_at']))}}</td>
                    <td>
                        <a style="color: #9955c6;" href="/console/shop/get?shopid={{$list['shopid']}}&cityid={{$cityid}}">详情</a>
                        <a style="margin: 0 10px;color: red;" href="#" onclick="on_the_shelf({{$list['shopid']}})">上架</a>
                        {{--<a href="#" onclick="delete_shop({{$list['shopid']}})">删除</a>--}}
                        <a style="color: #9955c6;" href="#" style="margin: 0 10px;" onclick="shop_eweima('{{$list['shopid']}}','{{$list['shopname']}}','{{$list['address']}}')">二维码</a>
                    </td>
                </tr>
            @endforeach
        </tbody>
    </table>
</section>
<ul class="delete goup">
    <li>
        <span>确认</span>
        <img class="fr" src="{{env('IMAGE_DOMAIN')}}/images/close_p.png" alt="">
    </li>
    <li style="line-height: 20px;margin-top: 30px;height: 108px;">
        <p class="fz_13">商家上架后，商家可设置自己的翻倍日。确定上架么？</p>
        <p style="margin-top: 15px;">
            <span style="position: relative;top: -40px;" class="fz_13">备注：</span>
            <textarea style="width: 270px;height: 50px;border: 1px solid #797979;" name="" id="" cols="30" rows="10"></textarea>
        </p>
    </li>
    <li>
        <button style="background-color: #9955c6;color: #fff;" class="fl">确定</button>
        <button class="fr">取消</button>
    </li>
</ul>
<ul class="delete delete1">
    <li>
        <span>确认</span>
        <img class="fr" src="{{env('IMAGE_DOMAIN')}}/images/close_p.png" alt="">
    </li>
    <li>删除商家,请谨慎操作! 确定删除么？</li>
    <li>
        <button style="background-color: #9955c6;color: #fff;" class="fl">确定</button>
        <button class="fr">取消</button>
    </li>
</ul>

<!-- 二维码  -->
<form action="" method="" class="shop_eweima">
    <div class="shop_title oh">
        <p class="fl">商家收款二维码</p>
        <img class="fr shop_close" src="{{env('IMAGE_DOMAIN')}}images/close_p.png" alt="">
    </div>
    <ul class="shop_eweima_content">
        <li id="output"></li>
        <li class="co_violet" style="font-size: 20px;"><span>门店名称 ：</span><span class="eweimashopname"></span></li>
        <li class="fz_16 co_gray56"><span>门店地址 ：</span><span class="eweimashopaddress"></span></li>
    </ul>
</form>
@endsection

@section('scriptResources')
    @parent
    <script type="text/javascript" src="{{env('JS_DOMAIN')}}js/jquery.qrcode.min.js"></script>
    <script src="{{env('JS_DOMAIN')}}js/jquery.dataTables.min.js?v={{env('JS_VERSION')}}"></script>
<script>
    var cityid='{{$cityid}}';
    var weburl = '{{env('WEB_URL')}}';
    $(document).ready(function(){
        $(".shop_go_up").click(function(){
            $(".goup").show();
        })
        $(".goup li img").click(function(){
            $(".goup").hide();
        })
        $(".shop_delete").click(function(){
            $(".delete1").show();
        })
        $(".delete1 li img").click(function(){
            $(".delete1").hide();
        })
    })
    $(".shop_close").on('click',function(){
        $(this).parent().parent().hide();
    })
    function on_the_shelf(shopid) {
        var isconfirm = confirm("确定上架?");
        var note = '';
        if(isconfirm) {
            $.ajax({
                url : '/console/shop/upshelf',
                type : 'post',
                data: {
                    'shopid':shopid,
                    'cityid':cityid,
                    'note': note
                },
                dataType:'json',
                success:function(data){
                    if(data.status == 'success') {
                        location.reload();
                    } else {
                        alert(data.message);
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        }
    }
    function delete_shop(shopid) {
        var isconfirm = confirm("确定删除?");
        var note = '';
        if(isconfirm) {
            $.ajax({
                url : '/console/shop/downshelf',
                type : 'post',
                data: {
                    'shopid':shopid,
                    'cityid':cityid,
                    'note': note
                },
                dataType:'json',
                success:function(data){
                    if(data.status == 'success') {
                        location.reload();
                    } else {
                        alert(data.message);
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        }
    }
    // 二维码
    function shop_eweima(shopid, shopname, address){
        $('#output').html("");
        $(".eweimashopname").text(shopname);
        $(".eweimashopaddress").text(address);
        $(".shop_eweima").show();
        //var qrcode = JSON.stringify({type:'payment', content:shopid});
        var qrcodeurl = weburl + "qrcode/shop/" + shopid;
        $('#output').qrcode(qrcodeurl);
    }
</script>
@endsection